<template>
  <a-card title="基本信息" class="add_edit_product">
    <a-form :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
      <div class="title">商品信息：</div>
      <a-form-item>
        <template slot="label">
          <span style="color: red">*</span>商品类型
        </template>
        <a-radio-group
          v-model="formData.productType"
          :disabled="
            source == 'order' ||
            (formData.flag == true && formData.productType == 3)
          "
          :options="productTypeList"
          @change="productTypeChange"
        ></a-radio-group>
      </a-form-item>
      <a-form-item>
        <template slot="label">
          <span style="color: red">*</span>商品名称
        </template>
        <a-input
          placeholder="输入商品名称"
          :maxLength="60"
          v-model="formData.productName"
          :disabled="source == 'order'"
          style="width: 200px"
        />
      </a-form-item>
      <a-form-item label="商品编码">
        <a-space>
          <a-input
            placeholder="输入商品编码"
            :maxLength="60"
            v-model="formData.productCode"
            style="width: 200px"
            :disabled="source == 'order' || isIntroduce"
          />
          <!-- <div class="desc">不填写系统生成</div> -->
       <!--   <a

            v-if="source != 'order'"
            href="javascript:;"
            @click="commodityLibShow = true"
            >商品库引入</a
          >-->
        </a-space>
      </a-form-item>
      <a-form-item>
        <template slot="label">
          <span style="color: red">*</span>商品分类
        </template>
        <a-space>
          <!-- <a-select placeholder="请选择" v-model="formData.productClassify" allowClear :options="commodityGroupList" style="width:200px"></a-select> -->
          <a-tree-select
            allowClear
            style="width: 200px"
            :replaceFields="{
              children: 'children',
              title: 'classifyName',
              key: 'id',
              value: 'id',
            }"
            v-model="formData.productClassify"
            :disabled="source == 'order' || (shopType == 2 && isIntroduce)"
            :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
            :tree-data="commodityClassifyList"
            placeholder="请选择"
            tree-default-expand-all
          >
            <span slot="title" slot-scope="{ value }">
              {{ value }}
            </span>
          </a-tree-select>
          <template v-if="source != 'order'">
            <a href="javascript:;" @click="productClassifyShow = true"
              >新建分类</a
            >
            |
            <a href="javascript:;" @click="handleRefreshProductClassify"
              >刷新</a
            >
          </template>
        </a-space>
        <div class="desc">商品分类用于店铺内部经营管理与财务利润核算</div>
      </a-form-item>
      <a-form-item>
        <template slot="label">
          <span style="color: red">*</span>商品分组
        </template>
        <a-space>
          <a-tree-select
            allowClear
            style="width: 200px"
            :replaceFields="{
              children: 'children',
              title: 'groupName',
              key: 'id',
              value: 'id',
            }"
            v-model="formData.productGroup"
            :disabled="source == 'order'"
            :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
            :tree-data="commodityGroupList"
            placeholder="请选择"
            tree-default-expand-all
          >
            <span slot="title" slot-scope="{ value }">
              {{ value }}
            </span>
          </a-tree-select>
          <!-- <div class="desc">商品分组用户C端小程序展示商品的分组使用</div> -->
        </a-space>
      </a-form-item>
      <a-form-item>
        <template slot="label">
          <span style="color: red">*</span>商品类目
        </template>
        <!-- <a-select placeholder="请选择" allowClear :options="commodityCategoryList" v-model="formData.productCategory" style="width:200px"></a-select> -->
        <a-space>
          <a-tree-select
            allowClear
            style="width: 200px"
            :replaceFields="{
              children: 'children',
              title: 'categoryName',
              key: 'id',
              value: 'id',
            }"
            v-model="formData.productCategory"
            :disabled="source == 'order'"
            :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
            :tree-data="commodityCategoryList"
            placeholder="请选择"
            tree-default-expand-all
          >
            <span slot="title" slot-scope="{ value }">
              {{ value }}
            </span>
          </a-tree-select>
        </a-space>
        <div class="desc">
          准确选择商品类目有助于完善商品信息与数据分析。商品类目及类目细项
        </div>
      </a-form-item>
      <a-form-item label="商品卖点">
        <a-textarea
          placeholder="请输入"
          style="width: 500px"
          :maxLength="60"
          v-model="formData.productPoints"
          :disabled="source == 'order'"
        ></a-textarea>
        <div class="desc">在商品详情页标题下面展示卖点信息，建议 60 字以内</div>
      </a-form-item>
      <a-form-item>
        <template slot="label">
          <span style="color: red">*</span>商品图片
        </template>
        <div class="product_image">
          <ImageUploadList
            :customUploadBtn="true"
            v-model="formData.imgList"
            :disabled="source == 'order'"
            @urls="handleSelectedUrls"
          >
            <template slot="uploadBtn">
              <div
                class="upload_btn"
                v-if="source != 'order'"
                @click="selectImageShow = true"
              >
                +
              </div>
            </template>
          </ImageUploadList>
        </div>
        <div class="desc">
          建议尺寸：640 x 640 像素；你可以拖拽图片调整图片顺序。最多上传15张
        </div>
      </a-form-item>
      <a-form-item label="商品视频">
        <UploadFileList
          :limit="1"
          :multiple="false"
          :value="formData.videoList"
          :disabled="source == 'order'"
          :isCustomBtn="true"
          accept=".mp4"
          @change="handleProductVideoChange"
        >
          <template slot="customBtn">
            <a-button v-if="source != 'order'" @click="selectVideoShow = true"
              ><a-icon type="upload" />点击上传</a-button
            >
          </template>
        </UploadFileList>
        <div class="desc">视频不能超过10M，支持mp4视频格式</div>
      </a-form-item>
      <a-form-item label="库存单位">
        <a-select
          v-model="formData.inventoryUnit"
          :disabled="source == 'order'"
          class="width200"
          :options="unitList"
        ></a-select>
      </a-form-item>
      <a-form-item label="分享描述">
        <a-textarea
          placeholder="请输入"
          v-model="formData.shareDescribe"
          :disabled="source == 'order'"
          style="width: 500px"
          :maxLength="32"
        ></a-textarea>
        <div class="desc">微信分享给好友时会显示，建议32个字以内</div>
      </a-form-item>
      <a-form-item label="虚拟销量">
        <a-input
          type="number"
          placeholder="可不填写，请填写虚拟销量"
          v-model="formData.virtualSales"
          :disabled="source == 'order'"
          style="width: 200px"
        />
      </a-form-item>

      <div class="title">商品规格信息：</div>
      <a-form-item>
        <template slot="label">
          <span style="color: red">*</span>商品型号
        </template>
        <a-radio-group
          :options="commodityModelList"
          v-model="formData.productModel"
          :disabled="source == 'order' || (shopType == 2 && isIntroduce)"
          style="width: 200px"
          @change="handleProductModelChange"
        />
      </a-form-item>
      <a-form-item>
        <template slot="label">
          <span style="color: red">*</span>商品所属
        </template>
        <a-radio-group
          :options="productAscriptionList"
          @change="productAscriptionChange"
          v-model="formData.productAscription"
          :disabled="source == 'order'"
        />
        <a-select
          style="width: 200px"
          :options="supplyGoodsList"
          v-model="formData.supplyGoods"
          :disabled="source == 'order'"
          placeholder="请选择供应商"
          v-if="formData.productAscription == 1"
        ></a-select>
      </a-form-item>
      <a-form-item label="购买商品返积分">
        <a-radio-group
          :options="pointsList"
          v-model="formData.buyPoints"
          :disabled="source == 'order'"
          style="width: 200px"
        />
        <div v-if="formData.buyPoints == 1">
          <a-radio-group
            v-model="formData.pointsType"
            :disabled="source == 'order'"
          >
            <a-row>
              <a-space>
                <a-radio :value="0" style="height: 40px; line-height: 40px"
                  >固定积分</a-radio
                >
                <template v-if="formData.pointsType == 0">
                  <a-input-number
                    :precision="0"
                    :min="0"
                    :max="99999999"
                    type="number"
                    style="width: 200px"
                    v-model="formData.fixedIntegral"
                    :disabled="source == 'order'"
                    placeholder="请填写返积分值"
                  />
                </template>
              </a-space>
            </a-row>
            <a-row>
              <a-space align="center">
                <a-radio :value="1" style="height: 40px; line-height: 40px"
                  >商品价格的百分比</a-radio
                >
                <template v-if="formData.pointsType == 1">
                  <a-input-number
                    :precision="0"
                    :min="0"
                    :max="100"
                    type="number"
                    style="width: 200px"
                    v-model="formData.percentage"
                    :disabled="source == 'order'"
                    placeholder="请填写返积分百分比"
                  />
                  <div class="desc">
                    使用去尾算法，不足1时去尾，比如积分为1.9，实际返积分为1
                  </div>
                </template>
              </a-space>
            </a-row>
          </a-radio-group>
        </div>
      </a-form-item>
      <!-- <a-form-item label="是否允许积分抵扣全额">
                <a-radio-group :options="fullDeductionList" v-model="formData.isAllowFullDeduction" style="width:200px;"/>
            </a-form-item>
            <a-form-item label="最大抵扣全额" v-if="formData.isAllowFullDeduction==2">
                <a-space>
                    <a-input-number :precision="2" :min="0" type="number" style="width:200px;" v-model="formData.maxFullDeduction" placeholder="请输入最大抵扣全额"/>元
                </a-space>
            </a-form-item> -->
      <a-form-item label="购买方式">
        <a-select
          style="width: 200px"
          v-model="formData.purchaseMethod"
          :disabled="source == 'order'"
          :options="buyWayList"
          @change="purchaseMethodChange"
        ></a-select>
      </a-form-item>
      <a-form-item v-if="formData.purchaseMethod == 1">
        <template slot="label">
          <span style="color: red">*</span>使用积分数量
        </template>
        <a-space>
          <a-input-number
            :precision="0"
            :min="0"
            :max="99999999"
            type="number"
            style="width: 200px"
            v-model="formData.integralCount"
            :disabled="source == 'order'"
            placeholder="请输入积分数量"
          />
        </a-space>
      </a-form-item>
      <!-- <a-form-item v-if="formData.purchaseMethod==1">
                <template slot="label">
                    是否和营销活动叠加使用
                </template>
                <a-radio-group :options="yesOrNo" v-model="formData.productModel" style="width:200px;" />
            </a-form-item> -->
      <template v-if="formData.productModel == 1">
        <a-form-item>
          <template slot="label">
            <span style="color: red">*</span>商品库存
          </template>
          <a-space>
            <a-input-number
              :precision="0"
              :min="0"
              :max="99999999"
              placeholder="请填写商品库存"
              v-model="formData.productSpecList[0].goodsInventory"
              :disabled="source == 'order' || (shopType == 2 && isIntroduce)"
              :maxLength="9"
              style="width: 130px"
            />
            件
          </a-space>
        </a-form-item>
        <a-form-item>
          <template slot="label">
            <span style="color: red">*</span>商品预警
          </template>
          <a-space>
            <a-input-number
              placeholder="请输入预警数量"
              v-model="formData.productWarning"
              :maxLength="9"
              :precision="0"
              :min="0"
              :max="99999999"
              style="width: 130px"
              :disabled="source == 'order' || (shopType == 2 && isIntroduce)"
            />
            件
          </a-space>
        </a-form-item>
        <a-form-item label="ERP编码">
          <a-input
            placeholder="选填 用于商家系统对接"
            v-model="formData.productSpecList[0].erpCode"
            style="width: 200px"
            :disabled="source == 'order' || (shopType == 2 && isIntroduce)"
          />
        </a-form-item>
        <a-form-item label="商品重量">
          <a-input-number
            :precision="2"
            :min="0"
            :max="99999999"
            placeholder="请输入商品重量"
            v-model="formData.productSpecList[0].goodsWeight"
            style="width: 200px"
            :disabled="source == 'order' || (shopType == 2 && isIntroduce)"
          />
        </a-form-item>
        <a-form-item>
          <a-col :offset="3">
            <table class="table">
              <thead>
                <tr>
                  <template
                    v-if="
                      formData.purchaseMethod == 0 ||
                      formData.purchaseMethod == 1
                    "
                  >
                    <th>市场价格（划线价）</th>
                    <th><span class="color_red">*</span>销售价格</th>
                    <th>返利价格</th>
                    <th>会员价</th>
                    <th>内部价</th>
                    <th>一级分销佣金</th>
                    <th>二级分销佣金</th>
                    <th>三级分销佣金</th>
                    <th v-if="formData.productAscription == 1">
                      <span class="color_red">*</span>供应商价格
                    </th>
                  </template>
                  <template v-else-if="formData.purchaseMethod == 2">
                    <th>市场价格（划线价）</th>
                    <th><span class="color_red">*</span>销售价格</th>
                    <th><span class="color_red">*</span>兑换价（积分）</th>
                    <th v-if="formData.productAscription == 1">
                      <span class="color_red">*</span>供应商价格
                    </th>
                  </template>
                  <template v-else-if="formData.purchaseMethod == 3">
                    <th>市场价格（划线价）</th>
                    <th><span class="color_red">*</span>兑换价（积分）</th>
                    <th v-if="formData.productAscription == 1">
                      <span class="color_red">*</span>供应商价格
                    </th>
                  </template>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <template
                    v-if="
                      formData.purchaseMethod == 0 ||
                      formData.purchaseMethod == 1
                    "
                  >
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].marketPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].salePrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].rebatePrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].membersPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].internalPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="
                          formData.productSpecList[0].oneLevelDistributionPrice
                        "
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="
                          formData.productSpecList[0].twoLevelDistributionPrice
                        "
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="
                          formData.productSpecList[0]
                            .threeLevelDistributionPrice
                        "
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td v-if="formData.productAscription == 1">
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].supplierPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                  </template>
                  <template v-else-if="formData.purchaseMethod == 2">
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].marketPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].salePrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].integralPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="0"
                        :min="0"
                      />
                    </td>
                    <td v-if="formData.productAscription == 1">
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].supplierPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                  </template>
                  <template v-else-if="formData.purchaseMethod == 3">
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].marketPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                    <td>
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].integralPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="0"
                        :min="0"
                      />
                    </td>
                    <td v-if="formData.productAscription == 1">
                      <a-input-number
                        placeholder="请输入"
                        v-model="formData.productSpecList[0].supplierPrice"
                        :disabled="
                          source == 'order' || (shopType == 2 && isIntroduce)
                        "
                        :precision="2"
                        :min="0"
                      />
                      (元)
                    </td>
                  </template>
                </tr>
              </tbody>
            </table>
          </a-col>
        </a-form-item>
      </template>
      <template v-if="formData.productType == 3">
        <a-form-item>
          <template slot="label"> 是否有赠品 </template>
          <a-radio-group
            @change="givingStatusChange"
            :options="pointsList"
            v-model="formData.givingStatus"
            :disabled="source == 'order'"
            style="width: 200px"
          />
          <a
            style="margin-left: 10px"
            href="javascript:;"
            @click="showGiftList()"
            v-if="source != 'order' && formData.givingStatus == 1"
            >请选择赠品</a
          >
        </a-form-item>
        <a-form-item v-if="giftTableData.length > 0">
          <a-col :offset="3">
            <a-table
              :rowKey="'goodsId'"
              :pagination="false"
              bordered
              :columns="giftColumns"
              :data-source="giftTableData"
            ></a-table>
          </a-col>
        </a-form-item>
      </template>

      <a-form-item>
        <template slot="label"> 是否支持开发票 </template>
        <a-radio-group
          :options="pointsList"
          v-model="formData.invoiceStatus"
          :disabled="source == 'order'"
          style="width: 200px"
        />
      </a-form-item>

      <template v-if="formData.productModel == 2">
        <a-form-item>
          <template slot="label">
            <span style="color: red">*</span>商品预警
          </template>
          <a-space>
            <a-input-number
              :precision="0"
              :min="0"
              :max="99999999"
              type="number"
              placeholder="请输入预警数量"
              v-model="formData.productWarning"
              :disabled="source == 'order' || (shopType == 2 && isIntroduce)"
              :maxLength="9"
              style="width: 130px"
            />
            件
          </a-space>
        </a-form-item>
        <a-form-item class="model">
          <MultiModel
            ref="MultiModelRef"
            :data="multiModelData"
            :source="source"
            :isSupplierProduct="formData.productAscription == 1 ? true : false"
            @change="handleTableChange"
          ></MultiModel>
        </a-form-item>
      </template>

      <div class="title">物流信息：</div>
      <a-form-item>
        <template slot="label">
          <span style="color: red">*</span>配送方式
        </template>
        <a-space>
          <a-checkbox-group
            v-model="formData.deliveryMode"
            :disabled="source == 'order'"
          >
            <a-checkbox :value="1" style="height: 40px; line-height: 40px"
              >快递发送</a-checkbox
            >
            <a-checkbox
              :value="2"
              style="height: 40px; line-height: 40px"
              :disabled="formData.productType == 3"
              >到店自提<a
                style="margin-left: 10px"
                href="javascript:;"
                @click="showAddress(3)"
                v-if="source != 'order' && formData.deliveryMode.includes(2)"
                >请选择自提地址</a
              ></a-checkbox
            >
            <a-checkbox
              :value="3"
              style="height: 40px; line-height: 40px"
              :disabled="formData.productType == 3"
              >定点配送<a
                style="margin-left: 10px"
                href="javascript:;"
                @click="showAddress(4)"
                v-if="source != 'order' && formData.deliveryMode.includes(3)"
                >请选择配送点</a
              ></a-checkbox
            >
          </a-checkbox-group>
        </a-space>
      </a-form-item>
      <a-form-item
        v-if="
          logisticsTableData.length > 0 && formData.deliveryMode.includes(2)
        "
      >
        <a-col :offset="3">
          <a-table
            :rowKey="(record) => record.id"
            :pagination="false"
            bordered
            :columns="logisticsColumns"
            :data-source="logisticsTableData"
          ></a-table>
        </a-col>
      </a-form-item>
      <a-form-item
        v-if="
          distributionTableData.length > 0 && formData.deliveryMode.includes(3)
        "
      >
        <a-col :offset="3">
          <a-table
            :rowKey="(record) => record.id"
            :pagination="false"
            bordered
            :columns="logisticsColumns"
            :data-source="distributionTableData"
          ></a-table>
        </a-col>
      </a-form-item>
      <a-form-item v-if="formData.deliveryMode.includes(1)" class="freightType">
        <template slot="label">
          <span style="color: red">*</span>快递运费
        </template>
        <!-- <a-space>
                    <a-radio-group v-model="formData.freightType" :options="expressFreightList"></a-radio-group>
                    <a-input type="number" v-model="formData.unifiedFreight"/>
                </a-space> -->
        <a-radio-group
          v-model="formData.freightType"
          :disabled="source == 'order'"
        >
          <a-row>
            <a-space>
              <a-radio :value="1" style="height: 40px; line-height: 40px"
                >统一运费</a-radio
              >
              <a-input-number
                :precision="2"
                :min="0"
                type="number"
                style="width: 200px"
                v-model="formData.unifiedFreight"
                :disabled="source == 'order'"
                v-if="formData.freightType == 1"
              />
            </a-space>
          </a-row>
          <a-row>
            <a-space>
              <a-radio :value="2" style="height: 40px; line-height: 40px"
                >运费模板</a-radio
              >
              <template v-if="formData.freightType == 2">
                <a-select
                  style="width: 200px"
                  v-model="formData.freightTemplateId"
                  :disabled="source == 'order'"
                  :options="freightTemplateList"
                ></a-select>
                <a href="javascript:;" @click="freightTemplateShow = true"
                  >新建运费模板</a
                >
                |
                <a href="javascript:;" @click="handleRefreshFreightTemplate"
                  >刷新</a
                >
              </template>
            </a-space>
            <div class="desc" style="margin-top: 8px">
              运费模版支持按地区设置运费，按购买件数计算运费，按重量计算运费等。
            </div>
          </a-row>
        </a-radio-group>
        <!-- <div class="desc">运费模版支持按地区设置运费，按购买件数计算运费，按重量计算运费等。</div> -->
      </a-form-item>

      <template v-if="isIntroduce">
        <div class="title">渠道设置：</div>
        <a-form-item label="店铺发布渠道">
          <a href="javascript:;" @click="shopShow = true">
            <template v-if="formData.shopIdList.length > 0">
              重新选择店铺
            </template>
            <template v-else> 选择店铺 </template>
          </a>
        </a-form-item>
      </template>

      <div class="title">商品详情：</div>
      <a-form-item>
        <a-col :offset="2">
          <tinymce-editor
            v-model="formData.productInfo"
            :disabled="source == 'order'"
          ></tinymce-editor>
        </a-col>
      </a-form-item>
      <a-form-item>
        <a-col :offset="2">
          <a-space>
            <a-button @click="handleCancel">取消</a-button>
            <a-button
              v-if="source != 'order'"
              type="primary"
              @click="submitData(1)"
              >提交保存</a-button
            >
            <a-button
              v-if="source != 'order'"
              type="primary"
              @click="submitData(2)"
              >保存并上架</a-button
            >
            <a-button @click="handlePreview">预览</a-button>
          </a-space>
        </a-col>
      </a-form-item>
    </a-form>
    <!-- <ProductIntroduce :isApi="false" :visible="introduceShow" @cancel="introduceShow=false" @change="handleProductIntroduce"></ProductIntroduce> -->
    <CommodityLibrary
      :visible="commodityLibShow"
      @cancel="commodityLibShow = false"
      @submit="handleSelectedCommodityLibrary"
    ></CommodityLibrary>
    <ShopList
      :visible="shopShow"
      :shopIds="formData.shopIdList"
      @cancel="shopShow = false"
      @submit="handleShopSubmit"
    ></ShopList>
    <ProductClassify
      :visible="productClassifyShow"
      @cancel="handleProductClassifyCancel"
    ></ProductClassify>
    <FreightTemplate
      :visible="freightTemplateShow"
      @cancel="handleFreightTemplateCancel"
    ></FreightTemplate>
    <ProductPreview
      :data="previewData"
      :visible="previewShow"
      @cancel="previewShow = false"
    ></ProductPreview>
    <ProductAddress
      ref="ProductAddress"
      :visible="addressShow"
      :type="addressType"
      :checkedIds="checkedIds"
      @cancel="addressShow = false"
      @submit="handleProductAddressSubmit"
    ></ProductAddress>
    <SelectImage
      :visible="selectImageShow"
      :selectedFileUrls="selectedFileUrls"
      @cancel="selectImageShow = false"
      @submit="handleSelectImageChange"
    ></SelectImage>
    <SelectVideo
      :visible="selectVideoShow"
      :selectedUrl="selectedVideoUrl"
      @cancel="selectVideoShow = false"
      @submit="handleSelectVideoChange"
    ></SelectVideo>
    <ChooseGift
      :visible="chooseGiftShow"
      :selectId="formData.goodsGiving.givingId"
      @cancel="chooseGiftShow = false"
      @submit="chooseGiftSubmit"
    ></ChooseGift>
  </a-card>
</template>

<script>
import {mapGetters} from 'vuex'
import deepCopy from '@/utils/deepCopy'
import { findDictNameByValue,createOptionsByDict } from '@/utils/dict'
import ImageUploadList from '@/components/form/UploadImage'
//import ImageUploadList from '../commodityLibrary/components/UploadImage'
import UploadFileList from '@/components/form/UploadFile'
import ImageUpload from '@/components/antBase/ImageUpload'
import CommodityLibrary from './components/CommodityLibrary';
import ShopList from '@/components/ShopList/ShopList';
import ProductClassify from '../commodityLibrary/components/ProductClassify';
import FreightTemplate from '../commodityLibrary/components/FreightTemplate';
import MultiModel from '../commodityLibrary/components/MultiModel';
import ProductPreview from '../commodityLibrary/components/ProductPreview';
import ProductAddress from '../commodityLibrary/components/ProductAddress';
import SelectImage from '../commodityLibrary/components/SelectImage';
import SelectVideo from '../commodityLibrary/components/SelectVideo';
import ChooseGift from './components/ChooseGift';

const productSpecList=[
    {
        id:'',	//商品规格id
        goodsInventory:'',	//商品库存数量
        erpCode:'',	//erp编码
        goodsWeight:'',	//商品重量（单位：g 克）
        marketPrice:'',	//市场价格（划线价，单位：分）
        integralPrice: '', // 积分价格
        salePrice:'',	//销售价格（单位：分）
        rebatePrice:'',	//返利价格（单位：分）
        membersPrice:'', //会员价
        internalPrice: '', // 内部价
        oneLevelDistributionPrice:'',	//一级分销价格（单位：分）
        twoLevelDistributionPrice:'',	//二级分销价格（单位：分）
        threeLevelDistributionPrice:'',	//三级分销价格（单位：分）
        supplierPrice: '', // 供应商价格（单位：分）
        modelPicture:'',	//商品型号图片
        superiorModelIds:'',
        modelIds:'',
    }
]
const moneyAndIntegralList=[
    {
        id:'',	//商品规格id
        goodsInventory:'',	//商品库存数量
        erpCode:'',	//erp编码
        goodsWeight:'',	//商品重量（单位：g 克）
        marketPrice:'',	//市场价格（划线价，单位：分）
        salePrice:'',	//销售价格（单位：分）
        integralPrice: '', // 积分价格
        supplierPrice: '', // 供应商价格（单位：分）
        modelPicture:'',	//商品型号图片
        superiorModelIds:'',
        modelIds:'',
    }
]
const integralList=[
    {
        id:'',	//商品规格id
        goodsInventory:'',	//商品库存数量
        erpCode:'',	//erp编码
        goodsWeight:'',	//商品重量（单位：g 克）
        marketPrice:'',	//市场价格（划线价，单位：分）
        integralPrice: '', // 积分价格
        supplierPrice: '', // 供应商价格（单位：分）
        modelPicture:'',	//商品型号图片
        superiorModelIds:'',
        modelIds:'',
    }
]
// const modelData=[
//     {
//         modelClassifyId:'',
//         isAddImg:true,
//         modelList:[
//             // {
//             //     label:'测试1',
//             //     value:'1',
//             // },
//             // {
//             //     label:'测试2',
//             //     value:'2',
//             // }
//         ]
//     }
// ]
const formData={
    productLibId:'',//商品库id，引入商品库商品编码不可编辑
    //商品信息
    productType:2,//商品类型
    productName:'',//商品名称
    productCode:'',//商品编码
    productClassify:'',//商品分类
    productGroup:'',//商品分组
    productCategory:'',//商品类目
    productPoints:'',//商品卖点
    imgList:'',//商品图片
    videoList:'',//商品视频
    inventoryUnit:'',//库存单位
    shareDescribe:'',//分享描述
    virtualSales:'',//虚拟销量

    //商品规格信息
    productModel:1,//商品型号
    productWarning:'',
    productUnitCode:'',//商品库存
    productSpecList:deepCopy(productSpecList),
    moneyAndIntegralList:deepCopy(moneyAndIntegralList),
    integralList:deepCopy(integralList),

    //物流信息
    deliveryMode:[],//配送方式
    unifiedFreight:'',//统一运费
    storeReleaseChanne:1,//店铺发布渠道
    productInfo:'',//商品详情

    //goodsBrandId:'',//品牌id
    shopIdList:[],//渠道发布店铺id集合

    //多级型号
    freightType:1,//快递运费
    freightTemplateId:'',//运费模板id
    //modelData:deepCopy(modelData),

    productAscription:0,//商品所属
    supplyGoods:'',//商品所属供应商
    buyPoints:0,//购买商品积分（是否返积分，0：否，1：是）
    pointsType:0,//积分类型[0固定积分，1商品价格的百分比]
    fixedIntegral:'',//固定积分
    percentage:'',//百分比积分
    //isAllowFullDeduction:1,//是否允许抵扣全额
    //maxFullDeduction:'',//最大抵扣全额
    purchaseMethod:'0',//支付方式，0：现金；1：现金+积分
    integralCount:'',//积分数量
    addressConfigId:[],//自提地址ID
    fixedPointAddress:[],//配送地址ID
    // 是否有赠品（0:否，1:是）
    givingStatus:0,
    //是否开具发票（0:否，1:是
    invoiceStatus:0,
    // 商品赠品
    flag:false,
    goodsGiving:{
        // 赠品主键id, 图片,有效期,名称
        id:'',
        givingId:'',
        givingName:'',
        goodsPictures:'',
        validPeriodUnit:''
    }
}
const logisticsColumns=[
    {
        title: '编号',
        dataIndex: 'id',
        key: 'id'
    },{
        title: '地址名称',
        dataIndex: 'addressName',
        key: 'addressName'
    },{
        title: '地址类型',
        dataIndex: 'addressType',
        key: 'addressType',
        customRender: (text, record) => findDictNameByValue('ADDRESS_TYPE', text)
    },{
        title: '联系人姓名',
        dataIndex: 'contactName',
        key: 'contactName'
    },{
        title: '地址',
        dataIndex: 'fullAddress',
        key: 'fullAddress'
    },{
        title: '联系电话',
        dataIndex: 'phone',
        key: 'phone'
    },
]

export default {
    components:{
        ImageUploadList,
        UploadFileList,
        ImageUpload,
        CommodityLibrary,
        ShopList,
        ProductClassify,
        FreightTemplate,
        MultiModel,
        ProductPreview,
        ProductAddress,
        SelectImage,
        SelectVideo,
        ChooseGift
    },
    computed:{

        id(){
            return this.$route.query.id || '';
        },
        userInfo(){
            return this.$store.getters.userInfo || {};
        },
        shopId(){
            return this.userInfo.shopId || '';
        },
        source() {
            return this.$route.query.source || '';
        },
        //:1,//总店1；分店2；供应商3
        shopType(){
            let shopType=this.$route.query.shopType;
            console.log(shopType)
            if(shopType){
                return shopType;
            }
            if(this.userInfo.shopRoleCode=='role:store:main'){
                return 1;
            }
            else if(this.userInfo.shopRoleCode=='role:store:branch'){
                return 2;
            }
            // else if(this.userInfo.shopRoleCode=='role:supplier'){
            // else if(this.userInfo.userIdType==2){
            else if(this.userInfo.userIdType==3){
                console.log(this.userInfo)
                return 3;
            }
        },
        productAscriptionList(){
            let list = []

            // if (this.userInfo.userIdType ===2){
            if (this.userInfo.userIdType ===3){
                list =  [
                   {
                    label:'供应商',
                    value:1
                   }
                ]
               this.formData.productAscription=1
                // 极端手段
           /*  setTimeout(()=>{
                 this.formData.supplyGoods= this.supplyGoodsList[0].value
             },3500)*/

            } else {
                if(this.formData.productType == 3){
                    list = [
                        {
                            label:'自营商品',
                            value:0
                        }
                    ]
                } else {
                    list = [
                        {
                            label:'自营商品',
                            value:0
                        },
                        {
                            label:'供应商',
                            value:1
                        }
                    ]
                }
                
            }

            return list
        }
    },
    data(){
        return {
            // 库存单位
            unitList: createOptionsByDict('GOOD_INVENTORY_UNIT'),
            // 商品购买方式
            buyWayList: createOptionsByDict('GOODS_BUY_WAY'),
            // 是否
            yesOrNo: createOptionsByDict('YES_NO'),
            isIntroduce:false,//是否引入商品库
            shopShow:false,//店铺
            productModelShow:false,//商品型号
            productClassifyShow:false,//添加商品类型
            commodityLibShow:false,
            freightTemplateShow:false,//运费模板
            //shopType:1,//总店1；分店2；供应商3
            //商品类型
            productTypeList:[
                {
                    label:'定制品',
                    value:1
                },{
                    label:'标品',
                    value:2
                },{
                    label:'虚拟商品',
                    value:3
                }
            ],
            //商品分类
            commodityClassifyList:[],
            //商品分组
            commodityGroupList:[],
            //商品类目
            commodityCategoryList:[],
            //商品型号
            commodityModelList:[
                {
                    label:'统一型号',
                    value:1
                },
                {
                    label:'多级型号',
                    value:2
                }
            ],
            //配送方式
            deliveryModeList:[
                {
                    label:'快递发送',
                    value:1
                },{
                    label:'到店自提',
                    value:2
                },{
                    label:'定点配送',
                    value:3
                }
            ],
            //快递运费
            // expressFreightList:[
            //     {
            //         label:'统一运费',
            //         value:1
            //     },
            //     // {
            //     //     label:'运费模板',
            //     //     value:2
            //     // }
            // ],
            //运费模板
            freightTemplateList:[
                // {
                //     label:'测试',
                //     value:1
                // },{
                //     label:'测试2',
                //     value:2
                // }
            ],
            //型号分类
            modelClassifyList:[
                // {
                //     label:'颜色',
                //     value:1
                // },{
                //     label:'颜色2',
                //     value:2
                // }
            ],
            formData,
            //多级型号
            multiModelData:[],
            //商品所属
          /*  productAscriptionList:[
                {
                    label:'自营商品',
                    value:0
                },{
                    label:'供应商',
                    value:1
                }
            ],*/
            //供应商品列表
            supplyGoodsList:[],
            //购买商品积分
            pointsList:[
                {
                    label:'否',
                    value:0
                },{
                    label:'是',
                    value:1
                }
            ],
            //抵扣全额列表
            // fullDeductionList:[
            //     {
            //         label:'否',
            //         value:1,
            //     },{
            //         label:'是',
            //         value:2
            //     }
            // ],
            previewShow:false,
            logisticsColumns,
            logisticsTableData:[],
            distributionTableData: [],
            giftColumns: [
                {
                    title: '商品名称',
                    dataIndex: 'goodsName',
                    key: 'goodsName',
                    customRender: (text, row) => {
                        console.log( row)
                        return <div class="product_td"><table-img src={row.goodsPicture}/><div class="product_name">{text}</div></div>
                    }
                },{
                    title: '商品规格',
                    dataIndex: 'validPeriodUnit',
                    key: 'validPeriodUnit',
                    customRender:(text,row)=>{
                        if (text ==1){
                            return "有效期:1年;"
                        }
                        else if (text ==2){
                            return "有效期: 3个月;"
                        }
                        else if (text ==3){
                            return "有效期:1个月;"
                        }else {
                            return text
                        }
                    }
                }
            ],
            giftTableData: [],
            addressShow:false,
            previewData:{},
            selectImageShow:false,
            selectedFileUrls:[],

            selectedVideoUrl:'',
            selectVideoShow:false,
            chooseGiftShow: false,
            addressType: 0,
            checkedIds: []
        }
    },
    watch:{
        shopType:{
            handler(newVal){
                console.log("shopType",newVal)
                if(newVal==3){
                    this.productAscriptionList=[
                        {
                            label:'供应商',
                            value:1
                        }
                    ];
                    this.formData.productAscription=1;
                }
            },
            immediate:true,
        },
        supplyGoodsList:{
            handler(newVal){
                if (newVal.length>0){
                        this.formData.supplyGoods= this.supplyGoodsList[0].value
                }
            },
            immediate:true,
        }
    },
    created(){
        this.resetData();
        console.log('this.userInfo',this.userInfo)
        console.log('priceAndInventoryColumn',this.priceAndInventoryColumn)
        this.getClassifyList();
        this.getProductCategory();  
        this.getProductGroup();
        this.getFreightTemplate();
        this.getModelClassifyList();
        this.getSupplierList();
        if(this.id){
            //alert(1)
            this.getProductInfo(this.id);
        }
    },
    methods:{
        showGiftList() {
            this.chooseGiftShow = true
        },
        showAddress(type) {
            this.addressShow = true
            this.addressType = type
            if(type == 3) {
                this.checkedIds = this.formData.addressConfigId
            } else if(type == 4) {
                this.checkedIds = this.formData.fixedPointAddress
            }
            this.$refs.ProductAddress.defaultParams.addressType = type
        },
        purchaseMethodChange(e) {
            this.formData.purchaseMethod = e
            if(this.$refs.MultiModelRef){
                this.$refs.MultiModelRef.purchaseMethod = e
                this.$refs.MultiModelRef.getModelDataByTableData(this.multiModelData)
            }
        },
        handleSelectVideoChange(url){
            this.formData.videoList=url;
            this.selectedVideoUrl=url;
            this.selectVideoShow=false;
        },
        handleSelectedUrls(urls){
            this.formData.imgList=urls;
            this.selectedFileUrls=urls.split(',');
        },
        handleSelectImageChange(urls){
            this.formData.imgList=urls.join(',');
            this.selectedFileUrls=urls;
            this.selectImageShow=false;
        },
        handleProductAddressSubmit(selectedKeys){
            if(this.addressType == 3) {
                this.formData.addressConfigId = selectedKeys
            } else if(this.addressType == 4){
                this.formData.fixedPointAddress = selectedKeys
            }
            this.addressShow=false;
            this.logisticsTableData=[];
            this.formData.addressConfigId.forEach(async id=>{
                await this.getAddressInfo(id,3);
            })
            this.distributionTableData=[]
            this.formData.fixedPointAddress.forEach(async id=>{
                await this.getAddressInfo(id,4);
            })
        },
        chooseGiftSubmit(data) {
            console.log("被选中的赠品信息",data)
            this.chooseGiftShow = false
            this.giftTableData = []
            this.giftTableData.push(data)
            this.formData.goodsGiving.givingId = data.goodsId
            this.formData.goodsGiving.givingName = data.goodsName


        },
        async getAddressInfo(id,type){
            let res=await this.$get('/address/config/id',{
                id,
            });
            if(res && res.returnCode=='1000'){
                if(type == 3) {
                    this.logisticsTableData.push(res.dataInfo || {});
                } else if(type == 4) {
                    this.distributionTableData.push(res.dataInfo || {});
                }
                
            }
        },
        //获取供应商列表  只获取入住国际银行的
        async getSupplierList(){
            let res=await this.$get('/supplier/page',{auditStatuse:1});
            this.supplyGoodsList=[];
            if(res && res.returnCode=='1000'){

                ((res.dataInfo || {}).records || []).forEach(item=>{

                    if(this.shopType==3){//供应商
                        if(item.isSupplier==1){

                            this.supplyGoodsList.push({
                                label:item.supplierName,
                                value:item.id,
                            });
                            // this.formData.supplyGoods = this.supplyGoodsList[0].value
                        }
                    }
                    else {
                        this.supplyGoodsList.push({
                            label:item.supplierName,
                            value:item.id,
                        });
                    }                    
                })
            }

            console.log('this.supplyGoodsList',this.supplyGoodsList)
        },
        //商品规格信息发生改变时触发
        handleTableChange(tableData){
            console.log(tableData);
            this.multiModelData=tableData || [];
        },
        handleShopSubmit(data){
            console.log(data);
            this.formData.shopIdList=data;
            this.shopShow=false;
        },
        handleFreightTemplateCancel(){
            this.freightTemplateShow=false;
            this.handleRefreshFreightTemplate();
        },
        handleProductClassifyCancel(){
            this.productClassifyShow=false;
            this.handleRefreshProductClassify();
        },
        //获取型号分类
        async getModelClassifyList(){
            let res=await this.$get('/goods/modelnorm/list',{
                parentId:0,
                shopId:this.shopId,   
            })
            if(res && res.returnCode=='1000'){
                res.dataInfo.forEach(item=>{
                    this.modelClassifyList.push({
                        value:item.id,
                        label:item.normName,
                    })
                });                
            }
        },
        //回退
        handleCancel(){
            if(this.source == 'order') {
                this.$router.push({
                    name: "OrderList",
                    query: {
                        back: true,
                    },
                })
            } else {
                this.$router.push({
                    name:'ProductCommodityManageCommodityManage',
                    query: {
                        current:this.$route.query.current
                    }
                })
            }
            
        },
        //刷新分类
        handleRefreshProductClassify(){
            this.getClassifyList();
        },
        //刷新运费模板
        handleRefreshFreightTemplate(){
            this.getFreightTemplate();
        },
        //重置
        resetData(){
            this.formData=deepCopy(formData);
        },
        //选择商品库
        handleSelectedCommodityLibrary(ids){
            let id=ids[0];
            this.commodityLibShow=false;
            this.isIntroduce=true;
            this.getProductLibraryInfo(id);
        },
        //获取商品库详情
        async getProductLibraryInfo(id){
            let res=await this.$get('/goods/repository/query',{
                id 
            });
            if(res && res.returnCode=='1000'){
                this.setProductInfo(res.dataInfo,true);
            }
        },
        //分类列表
        async getClassifyList(){
            let res=await this.$get('/goods/classify/tree',{
                shopId:this.userInfo.shopId || ''
            })
            if(res && res.returnCode=='1000'){
                this.commodityClassifyList=res.dataInfo;
            }
        },
        //商品分组
        async getProductGroup(){
            let res=await this.$get('/goods/group/tree',{
                shopId:this.userInfo.shopId || ''
            });
            if(res && res.returnCode=='1000'){
                this.commodityGroupList=res.dataInfo || [];
            }
            else {
                this.commodityGroupList=[];
            }
        },
        //商品类目
        async getProductCategory(){
            let res=await this.$get('/goods/category/tree',{
                categoryStatus:1
            });
            if(res && res.returnCode=='1000'){
                this.commodityCategoryList=res.dataInfo || [];
            }
            else {
                this.commodityCategoryList=[];
            }
        },
        //运费模板
        async getFreightTemplate(){
            let res=await this.$get('/fare/model/page',{
                current:1,
                size:100,
            });
            if(res && res.returnCode=='1000'){
                console.log('freightTemplateList',res.dataInfo.records)
                let dataInfo=(res.dataInfo || {}).records || [];
                let tmpData=[];
                dataInfo.forEach(item=>{
                    tmpData.push({
                        value:item.id,
                        label:item.fareName
                    })
                })
                this.freightTemplateList=tmpData;
            }
            else {
                this.freightTemplateList=[];
            }
        },
        //商品详情数据处理
        async setProductInfo(dataInfo,isProductLibrary=false){
            if(!dataInfo || !dataInfo.goodsSpecList || dataInfo.goodsSpecList.length==0){
                dataInfo.goodsSpecList=[
                    {
                        id:'',	//商品规格id
                        goodsInventory:'',	//商品库存数量
                        erpCode:'',	//erp编码
                        goodsWeight:'',	//商品重量（单位：g 克）
                        marketPrice:'',	//市场价格（划线价，单位：分）
                        integralPrice: '', // 积分价格
                        salePrice:'',	//销售价格（单位：分）
                        rebatePrice:'',	//返利价格（单位：分）
                        membersPrice: '', //会员价格（单位：分）
                        internalPrice: '', // 内部价
                        oneLevelDistributionPrice:'',	//一级分销价格（单位：分）
                        twoLevelDistributionPrice:'',	//二级分销价格（单位：分）
                        threeLevelDistributionPrice:'',	//三级分销价格（单位：分）
                        supplierPrice: '', // 供应商价格（单位：分）
                        superiorModelIds:'',	//上级商品型号分类id多个,隔开
                        modelIds:'',	//商品型号id,多个以,隔开
                        modelPicture:'',	//商品型号图片
                    }
                ]
            }
            else {
                dataInfo.goodsSpecList.forEach(item=>{                            
                    item.marketPrice=Number(((item.marketPrice || 0) / 100).toFixed(2));
                    item.integralPrice=Number((item.integralPrice || 0));
                    item.salePrice=Number(((item.salePrice || 0)/100).toFixed(2));
                    item.rebatePrice=Number(((item.rebatePrice || 0)/100).toFixed(2));
                    item.membersPrice=Number(((item.membersPrice || 0)/100).toFixed(2));
                    item.internalPrice=Number(((item.internalPrice || 0)/100).toFixed(2));
                    item.oneLevelDistributionPrice=Number(((item.oneLevelDistributionPrice || 0)/100).toFixed(2));
                    item.twoLevelDistributionPrice=Number(((item.twoLevelDistributionPrice || 0)/100).toFixed(2));
                    item.threeLevelDistributionPrice=Number(((item.threeLevelDistributionPrice || 0)/100).toFixed(2));
                    item.supplierPrice=Number(((item.supplierPrice || 0)/100).toFixed(2));
                    item.goodsWeight=Number(((item.goodsWeight || 0)/1000).toFixed(3));
                })
            }
            let deliveryMode=dataInfo.deliveryMode || '';
            if(deliveryMode){
                console.log('deliveryMode',deliveryMode,deliveryMode.split(','))
                deliveryMode=deliveryMode.split(',').map(item=>parseFloat(item));
            }
            else {
                deliveryMode=[];
            }
            this.formData={
                //商品信息
                productType:parseInt(dataInfo.goodsType) || 1,//商品类型
                productName:dataInfo.goodsName || '',//商品名称
                productCode:(this.$route.query.id&&this.$route.query.opration=='copy')?'': (dataInfo.goodsCode || ''),//商品编码
                productGroup:dataInfo.goodsGroupId || '',//商品分组
                productCategory: dataInfo.goodsCategoryId || '',//商品类目
                productClassify:dataInfo.goodsClassificationId || '',//商品类型
                productPoints:dataInfo.goodsSellingPoint || '',//商品卖点
                imgList:dataInfo.goodsPictures || '',//商品图片
                videoList:dataInfo.goodsVideo || '',//商品视频
                inventoryUnit:parseInt(dataInfo.goodsUnitCode) || '',//商品库存单位（1:件数）
                shareDescribe:dataInfo.shareDescription || '',//分享描述
                virtualSales:dataInfo.virtualSales || '',//虚拟销量

                //商品规格信息
                productModel:dataInfo.goodsModel || 1,//商品型号
                productWarning:dataInfo.goodsWarningNumber || 0,//商品预警
                //productUnitCode:dataInfo.goodsUnitCode || 0,//库存
                productSpecList:dataInfo.goodsSpecList || [],

                //物流信息
                deliveryMode,//配送方式
                unifiedFreight:((dataInfo.unifiedFreight || 0) / 100).toFixed(2) || '',//统一运费
                storeReleaseChanne:1,//店铺发布渠道
                productInfo:dataInfo.goodsDetails || '',//商品详情

                //goodsBrandId:dataInfo.goodsBrandId||'',//品牌id
                shopIdList:dataInfo.shopIdList||[],//渠道发布店铺id集合
                freightTemplateId:dataInfo.freightTemplateId||[],//运费模板id
                freightType:dataInfo.freightType||'',//快递运费

                //多级型号
                //modelData:deepCopy(modelData),

                productAscription:dataInfo.goodsSource || 0,//商品来源，0：自营；1：供应商
                supplyGoods:dataInfo.goodsSupplier || '',//供应商ID
                buyPoints:dataInfo.returnPoints || 0,//是否返积分，0：否，1：是
                pointsType:dataInfo.returnPointsWay || 0,//积分发放形式，0：固定，1：价格*比例，去除小数
                fixedIntegral:dataInfo.returnPointsFormula || '',//积分公式，return_points_way=0：固定值；=1比例
                percentage:dataInfo.returnPointsFormula || '',
                purchaseMethod:dataInfo.paymentWay?dataInfo.paymentWay.toString() : '0',//支付方式，0：现金；1：现金+积分
                integralCount:dataInfo.pointsLowerLimit || '',//积分使用下限
                addressConfigId:(dataInfo.addressConfigId || '').split(',').filter(item=>item),//自提地址ID
                fixedPointAddress:(dataInfo.fixedPointAddress || '').split(',').filter(item=>item),//配送地址ID

                givingStatus:dataInfo.givingStatus,// 是否有赠品
                invoiceStatus:dataInfo.invoiceStatus, // 是否开发票
                goodsGiving:{
                    // givingId:dataInfo.goodsGivingList.givingId,  // 赠品id
                    // validPeriodUnit:dataInfo.goodsGiving.validPeriodUnit
                }
            }
            if (this.formData.productType ==3){
                this.formData.flag = true
            }

            if (dataInfo.goodsGivingList !=null && dataInfo.goodsGivingList.length>0){
                    this.formData.goodsGiving.id   =  dataInfo.goodsGivingList[0].id
                    this.formData.goodsGiving.givingId   =  dataInfo.goodsGivingList[0].givingId
                    this.formData.goodsGiving.givingName   =   dataInfo.goodsGivingList[0].givingName
                    this.formData.goodsGiving.goodsPictures   =  dataInfo.goodsGivingList[0].goodsPictures
                    this.formData.goodsGiving.validPeriodUnit  =   dataInfo.goodsGivingList[0].validPeriodUnit
                    this.giftTableData.push({
                    goodsName:this.formData.goodsGiving.givingName ,
                    goodsPicture:this.formData.goodsGiving.goodsPictures,
                    validPeriodUnit:this.formData.goodsGiving.validPeriodUnit
                   })
            }
            this.selectedFileUrls=(dataInfo.goodsPictures && dataInfo.goodsPictures.split(',')) || [];
            this.selectedVideoUrl=dataInfo.goodsVideo || '';

                if(isProductLibrary){
                    this.formData.productLibId=dataInfo.id || '';//商品库id
                    if(this.$route.query.opration=='copy'){
                        this.isIntroduce=false
                    }else{
                        this.isIntroduce=true;
                    }
                }
                else {
                    this.formData.productLibId=dataInfo.goodsBarCodeId || '';//商品库id
                    if(this.formData.productLibId&&this.$route.query.opration!='copy'){
                        this.isIntroduce=true;
                    }
                    else {
                        this.isIntroduce=false;
                    }
                    this.formData.id=dataInfo.id;
                }
             

            this.logisticsTableData=[];
            this.formData.addressConfigId.forEach(async id=>{
                await this.getAddressInfo(id,3);
            })
            this.distributionTableData=[];
            this.formData.fixedPointAddress.forEach(async id=>{
                await this.getAddressInfo(id,4);
            })

            //多级型号表格数据拼接
            if(dataInfo.goodsModel==2){
                this.multiModelData=dataInfo.goodsSpecList || [];
                this.$nextTick(() => {
                    this.$refs.MultiModelRef.purchaseMethod = dataInfo.paymentWay?dataInfo.paymentWay.toString() : '0'
                })
            }
            console.log('this.formData',this.formData.deliveryMode)
        },
        //获取商品信息
        async getProductInfo(id){
            let res=await this.$get('/goods/query',{
                id 
            });
            if(res && res.returnCode=='1000'){
                let dataInfo=res.dataInfo || {};
                this.setProductInfo(dataInfo);
            }
        },
        handleProductImageChange(urls){
            console.log('urls',urls)
            this.formData.imgList=urls;
        },        
        handleProductVideoChange(urls){
            console.log('urls',urls)
            this.formData.videoList=urls;
        },
        //商品型号切换
        handleProductModelChange(e){
            this.formData.productWarning='';

            this.$nextTick(() => {
                if(this.$refs.MultiModelRef){
                    this.$refs.MultiModelRef.purchaseMethod = this.formData.purchaseMethod
                    this.$refs.MultiModelRef.getModelDataByTableData(this.multiModelData)
                }
                if(this.formData.productModel == 2 && this.$refs.MultiModelRef) {
                    this.$refs.MultiModelRef.supplierProductChecked(e.target.val)
                }
            })
        },
        // 商品所属切换
        productAscriptionChange(e) {
            if(e.target.val == 1) {
                this.$refs.MultiModelRef.supplierProductChecked(e.target.val)
            }
        },
        //预览
        handlePreview(){
            this.previewData=deepCopy(this.formData);
            if(this.previewData.productModel==2){ // 多级型号  
                this.previewData.goodsSpecList=deepCopy(this.multiModelData);
            }
            else {
                this.previewData.goodsSpecList=deepCopy(this.formData.productSpecList);
            }
            this.previewShow=true;
        },
        //获取型号型号标题
        async getTitleName(id){
            if(!parseInt(id)){
                return '';
            }
            let res = await this.$get('/goods/modelnorm/id',{
                id
            },false,true);
            if(res && res.returnCode=='1000'){
                return res.dataInfo.normName || '';
            }
            else {
                return '';
            }
        },
        //数据提交  //1保存商品；2保存并上架
        async submitData(status=''){

            console.log('供应商Id:',this.formData.supplyGoods)
            
            if(!this.formData.productType){
                this.$message.error('请输入商品类型')
                return
            }
            if(!this.formData.productName){
                this.$message.error('请输入商品名称')
                return
            }
            if(!this.formData.productClassify){
                this.$message.error('请选择商品分类')
                return
            }
            if(!this.formData.productGroup){
                this.$message.error('请选择商品分组')
                return
            }
            if(!this.formData.productCategory){
                this.$message.error('请选择商品类目')
                return
            }
            if(!this.formData.imgList){
                this.$message.error('请上传商品图片')
                return
            }
            if(!this.formData.productModel){
                this.$message.error('请选择商品型号')
                return
            }
            
            if(this.formData.productAscription==1){
                if(!this.formData.supplyGoods){
                    this.$message.error('请选择商品所属供应商');
                    return
                }
            }
            if(this.formData.buyPoints==1){
                if(this.formData.pointsType===0){
                    if(!this.formData.fixedIntegral){
                        this.$message.error('请输入固定积分');
                        return
                    }
                }
                else if(this.formData.pointsType===1){
                    if(!this.formData.percentage){
                        this.$message.error('请输入百分比积分');
                        return
                    }
                }
            }
            if(this.formData.purchaseMethod==1){
                if(!this.formData.integralCount){
                    this.$message.error('请输入积分数量');
                    return
                }
            } else {
                this.formData.integralCount=0;
                //alert(this.formData.integralCount)
            }

            let goodsSpecList=[];
            if(this.formData.productModel==1){//统一型号
                if(!this.formData.productSpecList[0].goodsInventory && this.formData.productSpecList[0].goodsInventory!==0){
                    this.$message.error('请输入商品库存数量')
                    return
                }
                if(!this.formData.productWarning && this.formData.productWarning!==0){
                    this.$message.error('请输入商品预警')
                    return
                }
                if(this.formData.productSpecList[0].goodsInventory<this.formData.productWarning){
                    this.$message.error('商品预警不能大于商品库存数量')
                    return
                }



                if(this.formData.purchaseMethod==0 || this.formData.purchaseMethod==1){
                    if(!this.formData.productSpecList[0].salePrice && this.formData.productSpecList[0].salePrice!==0){
                        this.$message.error('请输入销售价格')
                        return
                    }
                    // if(!this.formData.productSpecList[0].rebatePrice && this.formData.productSpecList[0].rebatePrice!==0){
                    //     this.$message.error('请输入返利价格')
                    //     return
                    // }
                } else if(this.formData.purchaseMethod==2){
                    if(!this.formData.productSpecList[0].salePrice || this.formData.productSpecList[0].salePrice==0){
                        this.$message.error('请输入销售价格')
                        return
                    }
                    if(!this.formData.productSpecList[0].integralPrice || this.formData.productSpecList[0].integralPrice==0){
                        this.$message.error('请输入积分')
                        return
                    }
                } else if(this.formData.purchaseMethod==3){
                    if(!this.formData.productSpecList[0].integralPrice || this.formData.productSpecList[0].integralPrice==0){
                        this.$message.error('请输入积分')
                        return
                    }
                }
                if(this.formData.productAscription == 1){
                    if(!this.formData.productSpecList[0].supplierPrice && this.formData.productSpecList[0].supplierPrice!==0){
                        this.$message.error('请输入供应商价格')
                        return
                    }
                }
                goodsSpecList=deepCopy(this.formData.productSpecList);
                if(this.formData.purchaseMethod==0 || this.formData.purchaseMethod==1 || this.formData.purchaseMethod==null){
                    goodsSpecList[0].marketPrice=Math.round((goodsSpecList[0].marketPrice || 0) * 10 * 10);
                    goodsSpecList[0].integralPrice=Math.round(goodsSpecList[0].integralPrice || 0)
                    goodsSpecList[0].salePrice=Math.round((goodsSpecList[0].salePrice || 0) * 10 * 10);
                    goodsSpecList[0].rebatePrice=Math.round((goodsSpecList[0].rebatePrice || 0) * 10 * 10);
                    goodsSpecList[0].membersPrice=Math.round((goodsSpecList[0].membersPrice || 0) * 10 * 10);
                    goodsSpecList[0].internalPrice=Math.round((goodsSpecList[0].internalPrice || 0) * 10 * 10);
                    goodsSpecList[0].oneLevelDistributionPrice=Math.round((goodsSpecList[0].oneLevelDistributionPrice || 0) * 10 * 10);
                    goodsSpecList[0].twoLevelDistributionPrice=Math.round((goodsSpecList[0].twoLevelDistributionPrice || 0) * 10 * 10);
                    goodsSpecList[0].threeLevelDistributionPrice=Math.round((goodsSpecList[0].threeLevelDistributionPrice || 0) * 10 * 10);
                    goodsSpecList[0].supplierPrice=Math.round((goodsSpecList[0].supplierPrice || 0) * 10 * 10);
                } else if (this.formData.purchaseMethod==2){
                    goodsSpecList[0].marketPrice=Math.round((goodsSpecList[0].marketPrice || 0) * 10 * 10);
                    goodsSpecList[0].integralPrice=Math.round(goodsSpecList[0].integralPrice || 0)
                    goodsSpecList[0].salePrice=Math.round((goodsSpecList[0].salePrice || 0) * 10 * 10);
                    goodsSpecList[0].rebatePrice=0;
                    goodsSpecList[0].membersPrice=0;
                    goodsSpecList[0].internalPrice=0;
                    goodsSpecList[0].oneLevelDistributionPrice=0;
                    goodsSpecList[0].twoLevelDistributionPrice=0;
                    goodsSpecList[0].threeLevelDistributionPrice=0;
                    goodsSpecList[0].supplierPrice=Math.round((goodsSpecList[0].supplierPrice || 0) * 10 * 10);
                } else if (this.formData.purchaseMethod==3){
                    goodsSpecList[0].marketPrice=Math.round((goodsSpecList[0].marketPrice || 0) * 10 * 10);
                    goodsSpecList[0].integralPrice=Math.round(goodsSpecList[0].integralPrice || 0)
                    goodsSpecList[0].salePrice=0;
                    goodsSpecList[0].rebatePrice=0;
                    goodsSpecList[0].membersPrice=0;
                    goodsSpecList[0].internalPrice=0;
                    goodsSpecList[0].oneLevelDistributionPrice=0;
                    goodsSpecList[0].twoLevelDistributionPrice=0;
                    goodsSpecList[0].threeLevelDistributionPrice=0;
                    goodsSpecList[0].supplierPrice=Math.round((goodsSpecList[0].supplierPrice || 0) * 10 * 10);
                }
            }
            else if(this.formData.productModel==2){//多级型号  
                goodsSpecList=deepCopy(this.multiModelData);

                if(!this.formData.productWarning && this.formData.productWarning!==0){
                    this.$message.error('请输入商品预警')
                    return
                }
                if(goodsSpecList.length>0){
                    for(let i=0;i<goodsSpecList.length;i++){
                        let item=goodsSpecList[i];
                        if(!item.isAddImg && !item.modelPicture){
                            this.$message.error('请上传规格图片')
                            return
                        }
                        if(!item.goodsInventory && item.goodsInventory!==0){
                            this.$message.error('请输入商品库存数量')
                            return
                        }
                        if(this.formData.purchaseMethod==0 || this.formData.purchaseMethod==1){
                            if(!item.salePrice && item.salePrice!==0){
                                this.$message.error('请输入销售价格')
                                return
                            }
                            // if(!item.rebatePrice && item.rebatePrice!==0){
                            //     this.$message.error('请输入返利价格')
                            //     return
                            // }
                        } else if(this.formData.purchaseMethod==2){
                            if(!item.salePrice || item.salePrice==0){
                                this.$message.error('请输入销售价格')
                                return
                            }
                            if(!item.integralPrice || item.integralPrice==0){
                                this.$message.error('请输入积分')
                                return
                            }
                        } else if(this.formData.purchaseMethod==3){
                            if(!item.integralPrice || item.integralPrice==0){
                                this.$message.error('请输入积分')
                                return
                            }
                        }
                        if(this.formData.productAscription == 1){
                            if(!item.supplierPrice && item.supplierPrice!==0){
                                this.$message.error('请输入供应商价格')
                                return
                            }
                        }
                        if(this.formData.purchaseMethod==0 || this.formData.purchaseMethod==1 || this.formData.purchaseMethod==null){
                            item.marketPrice=Math.round((item.marketPrice || 0) * 10 * 10);
                            item.integralPrice=Math.round(item.integralPrice || 0);
                            item.salePrice=Math.round((item.salePrice || 0) * 10 * 10);
                            item.rebatePrice=Math.round((item.rebatePrice || 0) * 10 * 10);
                            item.membersPrice=Math.round((item.membersPrice || 0) * 10 * 10);
                            item.internalPrice=Math.round((item.internalPrice || 0) * 10 * 10);
                            item.oneLevelDistributionPrice=Math.round((item.oneLevelDistributionPrice || 0) * 10 * 10);
                            item.twoLevelDistributionPrice=Math.round((item.twoLevelDistributionPrice || 0) * 10 * 10);
                            item.threeLevelDistributionPrice=Math.round((item.threeLevelDistributionPrice || 0) * 10 * 10);
                            item.supplierPrice=Math.round((item.supplierPrice || 0) * 10 * 10);
                            item.goodsWeight=Math.round((item.goodsWeight || 0) * 10 * 10 * 10);
                        } else if(this.formData.purchaseMethod==2){
                            item.marketPrice=Math.round((item.marketPrice || 0) * 10 * 10);
                            item.integralPrice=Math.round(item.integralPrice || 0)
                            item.salePrice=Math.round((item.salePrice || 0) * 10 * 10);
                            item.rebatePrice=0;
                            item.membersPrice=0;
                            item.internalPrice=0;
                            item.oneLevelDistributionPrice=0;
                            item.twoLevelDistributionPrice=0;
                            item.threeLevelDistributionPrice=0;
                            item.supplierPrice=Math.round((item.supplierPrice || 0) * 10 * 10);
                            item.goodsWeight=Math.round((item.goodsWeight || 0) * 10 * 10 * 10);
                        } else if(this.formData.purchaseMethod==3){
                            item.marketPrice=Math.round((item.marketPrice || 0) * 10 * 10);
                            item.integralPrice=Math.round(item.integralPrice || 0)
                            item.salePrice=0;
                            item.rebatePrice=0;
                            item.membersPrice=0;
                            item.internalPrice=0;
                            item.oneLevelDistributionPrice=0;
                            item.twoLevelDistributionPrice=0;
                            item.threeLevelDistributionPrice=0;
                            item.supplierPrice=Math.round((item.supplierPrice || 0) * 10 * 10);
                            item.goodsWeight=Math.round((item.goodsWeight || 0) * 10 * 10 * 10);
                        }
                    }
                }
                else {
                    this.$message.error('商品规格信息不能为空')
                    return
                }
            }
            if(this.formData.deliveryMode.length == 0){
                this.$message.error('请选择配送方式')
                return
            }            
            if(this.formData.deliveryMode.includes(2)){
                if(this.formData.addressConfigId.length==0){
                    this.$message.error('请选择自提地址')
                    return
                }
            }
            if(this.formData.deliveryMode.includes(3)){
                if(this.formData.fixedPointAddress.length==0){
                    this.$message.error('请选择定点配送地址')
                    return
                }
            }

            if(this.formData.deliveryMode.includes(1)){
                if(this.formData.freightType==1){//统一运费
                    if(!this.formData.unifiedFreight && this.formData.unifiedFreight!==0){
                        this.$message.error('统一运费不能为空')
                        return
                    }
                }
                else if(this.formData.freightType==2){//运费模板
                    if(!this.formData.freightTemplateId){
                        this.$message.error('运费模板不能为空')
                        return
                    }
                }
            }
            if(this.formData.productAscription==0){
                this.formData.supplyGoods = ''
            }

            //  当按钮落在赠品位置的时候，赠品givingId不能没有
            if(this.formData.givingStatus ==1 && !this.formData.goodsGiving.givingId){
                this.$message.error('请选择赠品')
                return
            }
            let params={
                goodsBarCodeId:this.formData.productLibId,//商品条码
                goodsType:this.formData.productType,//商品类型
                goodsName:this.formData.productName,//商品名称
                goodsCode:this.formData.productCode,//商品编码
                //goodsBrandId:this.formData.goodsBrandId,   //商品品牌id
                goodsGroupId:this.formData.productGroup,//商品分组id
                goodsClassificationId:this.formData.productClassify, //商品分类id
                goodsSellingPoint:this.formData.productPoints, //商品卖点
                goodsPictures:this.formData.imgList, //商品图片多个用,隔开
                goodsVideo:this.formData.videoList, //商品视频
                shareDescription:this.formData.shareDescribe, //分享描述
                virtualSales:this.formData.virtualSales, //虚拟销量
                goodsModel:this.formData.productModel, //商品型号（1：统一型号，2：多级型号）
                goodsUnitCode:this.formData.inventoryUnit,//商品库存单位（1:件数）
                goodsWarningNumber:this.formData.productWarning, //商品预警数量
                goodsSpecList:goodsSpecList, //List<GoodsSpec>	商品规格集合
                deliveryMode:this.formData.deliveryMode.join(','), //发货方式（1：快递发货，2：到店自取）多个用,隔开
                freightType:this.formData.freightType, //运费类型（1：统一运费，2：运费模板）
                unifiedFreight:Math.round(this.formData.unifiedFreight * 10 * 10), //统一运费（单位：分）运费类型为1时必传
                shopIdList:this.formData.shopIdList, //渠道发布店铺id集合
                goodsDetails:this.formData.productInfo, //商品详情
                goodsStatus:status, //商品保存状态（ 1:商品保存 2:商品保存上架 ）
                goodsSource:this.formData.productAscription,//商品来源，0：自营；1：供应商
                goodsSupplier:this.formData.supplyGoods,//供应商ID
                returnPoints:this.formData.buyPoints, //是否返积分，0：否，1：是
                returnPointsWay:this.formData.pointsType,//积分发放形式，0：固定，1：价格*比例，去除小数
                returnPointsFormula:this.formData.pointsType==1?this.formData.percentage:this.formData.fixedIntegral,//积分公式，return_points_way=0：固定值；=1比例
                paymentWay:this.formData.purchaseMethod,//支付方式，1：现金；2：现金+积分
                pointsLowerLimit:this.formData.integralCount,//积分使用下限
                addressConfigId:this.formData.addressConfigId.join(','),//自提地址ID
                fixedPointAddress:this.formData.fixedPointAddress.join(','),//配送地址ID
                givingStatus:this.formData.givingStatus,// 是否有赠品
                invoiceStatus:this.formData.invoiceStatus, // 是否开发票
                // validPeriodUnit:this.formData.goodsGiving.validPeriodUnit,

            }

            if (params.goodsType == 3){
                params = {...params,
                        goodsGiving:{
                        id:!!this.formData.goodsGiving.id ? this.formData.goodsGiving.id : "",
                        givingId:this.formData.goodsGiving.givingId,  // 赠品id
                        givingName:this.formData.goodsGiving.givingName
                    }}
            }
            if(this.shopType!=2){//不是店铺分店
                params.goodsCategoryId=this.formData.productCategory;    //商品类目id
                //params.goodsUnitCode=this.formData.productUnitCode;      //商品库存单位（1:件数）
            }
            if(this.formData.freightType==2){//运费模板
                params.freightTemplateId=this.formData.freightTemplateId;
            }
            console.log(params)

          let url='/goods/add';
          if(this.id && this.$route.query.opration=='update'){
            url= '/goods/update';
            params.id=this.id;
          }
            let res = await this.$post(url, params);
            if(res && res.returnCode=='1000'){
                //this.resetData();
                console.log(this.formData,formData)
                if(status==1){//商品保存
                    this.$router.push({
                        name:'ProductCommodityManageCommodityManage',
                        query: {
                            current:this.$route.query.current
                        }
                    })
                    return this.$message.success('商品保存成功！');
                }
                else if(status==2){//保存上架                 
                    this.$router.push({
                        name:'ProductCommodityManageCommodityManage',
                        query: {
                            current:this.$route.query.current
                        }
                    })
                    return this.$message.success('商品保存并上架成功！');
                }
            }
            else{
                if(status==1){//商品保存
                    return this.$message.success('商品保存失败！');
                }
                else if(status==2){//保存上架
                    return this.$message.error('商品保存并上架失败！');
                }
            }
        },

        givingStatusChange(e){

            if(this.formData.givingStatus == 0){
                this.giftTableData = []
                // 清空赠品id等信息
                // 赠品主键id, 图片,有效期,名称
             /*  this.formData.goodsGiving ={

                        id:'',
                        givingId:'',
                        givingName:'',
                        goodsPictures:'',
                        validPeriodUnit:''
                }*/
                this.formData.goodsGiving.givingId = ''
                this.formData.goodsGiving.givingName = ''
                this.formData.goodsGiving.goodsPictures = ''
                this.formData.goodsGiving.validPeriodUnit = ''
            }

        },

        productTypeChange(e){
            console.log(e.target.value);
            if (e.target.value!=3){
                this.giftTableData = []
                // 清空赠品id等信息
                this.formData.goodsGiving ={
                    // 赠品主键id, 图片,有效期,名称
                    id:'',
                    givingId:'',
                    givingName:'',
                    goodsPictures:'',
                    validPeriodUnit:''
                }
            }


        }
    }
}
</script>

<style lang="less" scoped>
.title {
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 24px;
}
.desc {
  color: #ccc;
}
/deep/ .input_text {
  width: 200px !important;
  height: 32px !important;
  border: 1px solid #d9d9d9 !important;
  border-radius: 4px !important;
}
.table {
  border: 1px solid #e6e6e6;
  background: #fff;
  thead {
    tr {
      th {
        border: 1px solid #e6e6e6;
        white-space: nowrap;
        text-align: center;
        background: #f5f5f5;
      }
    }
  }
  tbody {
    tr:last-child {
      text-align: center;
    }
    tr {
      th,
      td {
        border: 1px solid #e6e6e6;
        //padding:4px 10px;
        white-space: nowrap;
        position: relative;
        text-align: center;
        .dynamic-delete-button {
          position: absolute;
          right: -0.3rem;
          top: 15px;
          cursor: pointer;
        }
        input[type="text"],
        input[type="number"] {
          border: none;
          outline: none;
          box-sizing: border-box;
          height: 40px;
        }
        input[type="number"] {
          line-height: 1;
        }
      }
      th {
        input[type="text"] {
          text-align: center;
        }
      }
      td {
        input[type="text"],
        input[type="number"] {
          // min-width:80px;
          // width:100%;
          width: 100px;
        }
        .row {
          line-height: 0.6rem;
          border-bottom: 1px solid #e6e6e6;
          &:last-child {
            border-bottom: none;
          }
        }
      }
    }
  }
  tfoot {
    td {
      background: #f5f5f5;
      text-align: center;
      a {
        font-size: 12px;
      }
    }
  }
}
.panel {
  border: 1px solid #e6e6e6;
  border-radius: 4px;
  margin-bottom: 10px;
  .header {
    background: #f5f5f5;
    border-bottom: 1px solid #e6e6e6;
    padding: 3px 15px;
    .left {
      white-space: nowrap;
    }
    .right {
      a {
        white-space: nowrap;
      }
    }
  }
  // .body{

  // }
}
.flex {
  display: flex;
  align-items: center;
  &.between {
    justify-content: space-between;
  }
  &.start {
    align-items: flex-start;
  }
}
.width100 {
  width: 100px;
}
.width150 {
  width: 150px;
}
.width200 {
  width: 200px;
}
.text_right {
  text-align: right;
}
.color_red {
  color: red;
}
.freightType {
  .ant-row {
    margin-bottom: 10px;
    &:last-child {
      margin-bottom: 0;
    }
  }
}
.product_picture {
  width: 60px;
  height: 60px;
  display: block;
}
.relative {
  position: relative;
  .delete {
    position: absolute;
    right: -40px;
  }
}
.table {
  /deep/ .ant-upload.ant-upload-select-picture-card {
    margin-bottom: 0;
    margin-right: 0;
  }
  /deep/ .ant-upload-picture-card-wrapper {
    display: block;
  }
}
// /deep/ .ant-upload-picture-card-wrapper{
//     //display:none;
// }
// /deep/ .product_image{
//     //display: flex;
// }
.upload_btn {
  width: 104px;
  height: 104px;
  margin: 0 8px 8px 0;
  text-align: center;
  font-size: 24px;
  cursor: pointer;
  line-height: 96px;
  padding: 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fafafa;
  display: inline-block;
}
</style>


